package com.ruoyi.finance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finance.domain.PaymentDetail;
import com.ruoyi.finance.service.IPaymentDetailService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 付款单详情Controller
 *
 * @author lvql
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/paymentDetail")
public class PaymentDetailController extends BaseController
{
    @Autowired
    private IPaymentDetailService paymentDetailService;

    /**
     * 查询付款单详情列表
     */
    @RequiresPermissions("finance:paymentDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(PaymentDetail paymentDetail)
    {
        startPage();
        List<PaymentDetail> list = paymentDetailService.selectPaymentDetailList(paymentDetail);
        return getDataTable(list);
    }

    /**
     * 导出付款单详情列表
     */
    @RequiresPermissions("finance:paymentDetail:export")
    @Log(title = "付款单详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaymentDetail paymentDetail)
    {
        List<PaymentDetail> list = paymentDetailService.selectPaymentDetailList(paymentDetail);
        ExcelUtil<PaymentDetail> util = new ExcelUtil<PaymentDetail>(PaymentDetail.class);
        util.exportExcel(response, list, "付款单详情数据");
    }

    /**
     * 获取付款单详情详细信息
     */
    @RequiresPermissions("finance:paymentDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(paymentDetailService.selectPaymentDetailById(id));
    }

    /**
     * 新增付款单详情
     */
    @RequiresPermissions("finance:paymentDetail:add")
    @Log(title = "付款单详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaymentDetail paymentDetail)
    {
        return toAjax(paymentDetailService.insertPaymentDetail(paymentDetail));
    }

    /**
     * 修改付款单详情
     */
    @RequiresPermissions("finance:paymentDetail:edit")
    @Log(title = "付款单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaymentDetail paymentDetail)
    {
        return toAjax(paymentDetailService.updatePaymentDetail(paymentDetail));
    }

    /**
     * 删除付款单详情
     */
    @RequiresPermissions("finance:paymentDetail:remove")
    @Log(title = "付款单详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(paymentDetailService.deletePaymentDetailByIds(ids));
    }
}
